<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<meta name="description" content="">
		<meta name="author" content="">

		<title>Dashboard Template for Bootstrap</title>
		<!-- Bootstrap core CSS -->
		<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
		<!-- Custom styles for this template -->
		<link th:href="@{/css/dashboard.css}" rel="stylesheet">
		<style type="text/css">
			/* Chart.js */
			@-webkit-keyframes chartjs-render-animation {
				from {
					opacity: 0.99
				}
				to {
					opacity: 1
				}
			}
			@keyframes chartjs-render-animation {
				from {
					opacity: 0.99
				}
				to {
					opacity: 1
				}
			}
		</style>
	</head>

	<body>
	<div th:replace="~{commons/commons::topbar}"></div>

		<div class="container-fluid">
			<div class="row">
				<div th:replace="~{commons/commons::sidebar(active='listStudent.html')}"/>

				<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
					<div class="table-responsive">
						<table class="table table-striped table-sm">
							<thead>
							<form action="/admin/getStudent" method="get">
								<tr>
									<div class="form-group">
										<label>学生姓名</label>
										<input type="text" name="name" id="name" class="form-control" placeholder="请输入学生姓名">
									</div>
									<input type="submit" value="查询"/>
								</tr>
							</form>
							<tr>
								<th type="hidden"></th>
								<th>姓名</th>
								<th>年龄</th>
								<th>地址</th>
								<th>操作</th>
							</tr>
							</thead>
							<tbody>
								<tr th:each="student:${studentList}">
									<td>
										<input type="hidden" id="studentId" th:value="${student.getId()}">
									</td>
									<td th:text="${student.getName()}"></td>
									<td th:text="${student.getAge()}"></td>
									<td th:text="${student.getAddress()}"></td>
									<td>
										<a th:href="@{/admin/toUpdateStudent/}+${student.getId()}">修改</a>
										<input type="button" onclick="javascript:
									$.ajax({
										url:'http://localhost:8080/admin/deleteStudent',
										type: 'GET',
										data:{'studentId':$('#studentId').val()},
										datatype: 'json',
										success: function (data) {
										if(data.code == '0'){
										window.location.href = 'http://localhost:8080/admin/listStudent';
										}else{
										alert('异常');
										}
										}
									});" value="删除"/>
									</td>
								</tr>
							<tr>
<!--								<td colspan="8">-->
<!--									<div class="pagelist">-->
<!--										<p>当前<span th:text="${studentList.getNumber()} + 1"></span>页,总<span th:text="${studentList.totalPages}"></span>页-->
<!--											　　　　　　　　　　　　　　　　　共<span th:text="${studentList.totalElements}"></span>条记录-->
<!--											<a th:href="@{/admin/getStudent}">首页</a>-->
<!--											<a th:href="@{/admin/getStudent(pageNum = ${studentList.hasPrevious()} ? ${studentList.getNumber() } : 1)}">上一页</a>-->
<!--											<a th:href="@{/admin/getStudent(pageNum = ${studentList.hasNext()} ? ${studentList.getNumber()} + 2 : ${studentList.totalPages})}">下一页</a>-->
<!--											<a th:href="@{/admin/getStudent(pageNum = ${studentList.totalPages})}">尾页</a></p>-->
<!--									</div>-->
<!--								</td>-->
							</tr>
							</tbody>
						</table>
					</div>
				</main>
			</div>
		</div>

		<!-- Bootstrap core JavaScript
    ================================================== -->
		<!-- Placed at the end of the document so the pages load faster -->
		<script type="text/javascript" th:src="@{/js/jquery-3.4.1.min.js}"/>
		<script type="text/javascript" th:src="@{/js/jquery-3.2.1.slim.min.js}"></script>
		<script type="text/javascript" th:src="@{/js/popper.min.js}"></script>
		<script type="text/javascript" th:src="@{/js/bootstrap.min.js}"></script>
		<!-- Graphs -->
		<script type="text/javascript" th:src="@{/js/Chart.min.js}"></script>
	</body>
</html>